package cn.agilean.test.rest;

import cn.agilean.test.service.ProductManager;
import cn.agilean.test.vo.ProductVo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("products")
public class ProductApi {
    private ProductManager productManager;

    public ProductApi(ProductManager productManager) {
        this.productManager = productManager;
    }

    @RequestMapping("getByProductId")
    public ProductVo getByProductId(@RequestParam("id")String id){
        ProductVo productVo = productManager.getByProductId(id);
        return productVo;
    }

    @RequestMapping("getAll")
    public List<ProductVo> getAll(){
        List<ProductVo> all = productManager.getAll();
        return all;
    }

}
